// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-12

package kind

// RefundState
// 退单状态.
type RefundState int

const (
	RefundStateNot        RefundState = 1 // 未退
	RefundStateRefused    RefundState = 2 // 申请被拒
	RefundStateApplied    RefundState = 3 // 退单申请, 待处理
	RefundStateProcessing RefundState = 4 // 退单处理中
	RefundStateFailed     RefundState = 5 // 退单失败
	RefundStateSucceed    RefundState = 6 // 退单成功
)

var (
	refundStateTexts = map[RefundState]string{
		RefundStateNot:        "未退",
		RefundStateRefused:    "退单被拒",
		RefundStateApplied:    "待确认",
		RefundStateProcessing: "处理中",
		RefundStateFailed:     "处理失败",
		RefundStateSucceed:    "处理成功",
	}

	refundStateFlags = map[RefundState]string{
		RefundStateNot:        "not",
		RefundStateRefused:    "refused",
		RefundStateApplied:    "applied",
		RefundStateProcessing: "processing",
		RefundStateFailed:     "failed",
		RefundStateSucceed:    "succeed",
	}
)

func RefundStateDict() []map[string]any {
	var res = make([]map[string]any, 0)
	for _, v := range []RefundState{
		RefundStateRefused,
		RefundStateApplied,
		RefundStateProcessing,
		RefundStateFailed,
		RefundStateSucceed,
	} {
		res = append(res, map[string]any{
			"Key":   v,
			"Value": v.Text(),
		})
	}
	return res
}

func (o RefundState) IsNot() bool        { return o == RefundStateNot }
func (o RefundState) IsRefused() bool    { return o == RefundStateRefused }
func (o RefundState) IsApplied() bool    { return o == RefundStateApplied }
func (o RefundState) IsProcessing() bool { return o == RefundStateProcessing }
func (o RefundState) IsFailed() bool     { return o == RefundStateFailed }
func (o RefundState) IsSucceed() bool    { return o == RefundStateSucceed }

func (o RefundState) Flag() string {
	if str, ok := refundStateFlags[o]; ok {
		return str
	}
	return ""
}

func (o RefundState) Text() string {
	if str, ok := refundStateTexts[o]; ok {
		return str
	}
	return ""
}
